#!/usr/bin/env bash
set -e
mkdir -p /opt/tmp/
yum install -y unzip zip zlib zlib-devel openssl-devel

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar -xvzf Python-3.5.2.tgz
mv Python-3.5.2.tgz /opt/tmp
cd Python-3.5.2
./configure --prefix=/opt/python3
make && make install



# todo 原则用python3
mv /usr/bin/python /usr/bin/python2.7.5
ln -s /opt/python3/bin/python3.5 /usr/bin/python

perl -p -i -e "s/\#\!\/usr\/bin\/python/\#\!\/usr\/bin\/python2.7.5/g" /usr/bin/yum
perl -p -i -e "s/\/usr\/bin\/python/\/usr\/bin\/python2.7.5/g" /usr/libexec/urlgrabber-ext-down




wget https://pypi.python.org/packages/69/56/f0f52281b5175e3d9ca8623dadbc3b684e66350ea9e0006736194b265e99/setuptools-38.2.4.zip
unzip setuptools-38.2.4.zip
mv setuptools-38.2.4 /opt/setuptools-38.2.4
mv setuptools-38.2.4.zip /opt/tmp
cd  /opt/setuptools-38.2.4/

python  setup.py build
python  setup.py install




wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
tar -zxvf pip-9.0.1.tar.gz
mv pip-9.0.1.tar.gz /opt/tmp
mv pip-9.0.1 /opt/
cd /opt/pip-9.0.1/

python setup.py build
python setup.py install
ln -s /opt/python3/bin/pip3      /usr/bin/pip3

mv ../Python-3.5.2 /opt
#pip3 install tensorflow

echo -e "PATH=/opt/python3/bin:$PATH">>/etc/profile


# shell头指向2.7    用python3命令吧
# /usr/bin/yum
#vi  /usr/libexec/urlgrabber-ext-down
#http://blog.csdn.net/hu19921016/article/details/72236966

#pip3#建好软链https://www.cnblogs.com/chengd/p/7078588.html

